#include "../Unit--/unit--.h"
#include "../../wmi_connection.h"
#include "../../wmi_connectionmanager.h"
#include <comdef.h>
#include <Wbemidl.h>
#include "../../wmi_registry.h"
#include "../../wmi_registrymanager.h"
#include "../../wmi_constants.h"

# pragma comment(lib, "wbemuuid.lib")

using namespace unit_minus;
using namespace std;

testSuite(WMIReaderSuite);

testCase(RegMngTest1, WMIReaderSuite)
{
    cout << "---------- Start WMI_RegistryManager Test ----------" << endl;
    WMI_Connection con;
    WMI_HResult* whres;
	WMI_ConnectionManager* mng = new WMI_ConnectionManager();
	whres = mng->initCOMSecurityConfiguration();
    delete whres;

	whres = mng->createConnection(PC_LOCAL_USER, PC_LOCAL_PASSWORD, PC_NAMESPACE_REG, con);
    delete whres;

	WMI_RegistryManager man(&con);

 	WMI_Registry* rclass=new WMI_Registry();

	assertTrue(rclass->getName() == CONST_HKEY_LOCAL);

	whres = man.getRegistrys(R_LOCAL_MACHINE,EMPTY_SUBKEY,&rclass);
    delete whres;

	assertTrue(rclass->getRegistryList().size()>0);

	for(int i = 0;i < rclass->getRegistryList().size(); i++)
	{
		if(rclass->getRegistryList().at(i)->getName() == HW)
		{
			assertTrue(rclass->getRegistryList().at(i)->getName() == HW);
		}
	}

	vector<WMI_Registry> reg;
	man.getStandardRegistryHives(reg);
	
	cout << "******** Predefined Registry Hives********* " << endl;
	for(vector<WMI_Registry>::iterator i = reg.begin(); i != reg.end(); i++)
		(*i).print();

	assertTrue(4 == reg.size())

	con.close();
    cout << "---------- End WMI_RegistryManager Test ----------" << endl << endl;
    system("PAUSE");
}

